﻿using MediatR;
using RBAC.Common.Domains;
using RBAC.Common.Dto;
using RBAC.Common.infrastructures.interfaces;
using RBAC.Enum;

namespace RBAC.api.Application.commond.RBAC
{
    public class UserLoginHander : IRequestHandler<UserLoginCommond, Rulst>
    {





        private readonly IbaseRpository<User> _user;

        public UserLoginHander(IbaseRpository<User> user)
        {
            _user = user;
        }

        public async Task<Rulst> Handle(UserLoginCommond request, CancellationToken cancellationToken)
        {


            var query = new Rulst() { Code = (int)Reult.success };



            query.data = _user.Query().Where(x => x.UserName == request.Acoount && x.Password == request.Password).FirstOrDefault();


            query.Code=(int)Reult.success;
            return query;



        }
    }
}
